<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        {{num}}姓名{{username}}
        <div>年龄:{{userage}}</div>
        <button @click="add">修改年龄</button>
    </div>
</body>
<script>
    function MyVue(options){
        this.target = document.querySelector(options.el)
        let html = this.target.innerHTML
        console.log(html);

        let data = options.data
        let keys = Object.keys(data);
        console.log(keys);
        keys.forEach(key=>{
            html = html.replace(`{{${key}}}`,data[key])
        })
        this.target.innerHTML = html
    }

    function MyVue(options){
        this.target = document.querySelector(options.el)
        let html = this.target.innerHTML
        console.log(html);

        let data = options.data
        let keys = Object.keys(data);
        console.log(keys);
    }


    new MyVue({
        el: "#app",
        data: {
            num: 10,
            username: "leson",
            userage: 18
        },
        methods: {
            add() {
                this.$data.userage++;
            }
        }
    });
</script>

</html>